'''
Created on Nov 6, 2009

@author: kage
'''

from PyQt4 import QtCore

from PyBatch.audio.extractor import  AudioExtractor
from PyBatch.audio.replacer import AudioReplacer

from PyBatch.video.extractor import VideoExtractor
from PyBatch.video.muxer import Muxer
from PyBatch.video.remuxer import Remuxer

from PyBatch.converters.avitomkv import AvitoMkv
from PyBatch.converters.mp4tomkv import Mp4toMkv

class Converter(QtCore.QThread):
    def __init__(self, args=None):
        QtCore.QThread.__init__(self)
        self.convertDict = {}
        self.mode = ''
        
        self.convertDict['audioExtractor'] = AudioExtractor(args)
        self.convertDict['audioReplacer'] = AudioReplacer(args)
        
        self.convertDict['videoExtractor'] = VideoExtractor(args)
        self.convertDict['muxer'] = Muxer(args)
        self.convertDict['remuxer'] = Remuxer(args)
        
        self.convertDict['aviToMkv'] = AvitoMkv(args)
        self.convertDict['mp4ToMkv'] = Mp4toMkv(args)
        self.args = {}
    
    def setmode(self, mode):
        self.mode = mode
    
    def setExt(self,ext):
        self.ext = ext
    
    def convert(self, args=None):
        self.args = args
        self.start()
        
    def errorCode(self):
        return self.convertDict[self.mode].errorCode()
    
    def setCommandLine(self, data):
        self.convertDict[self.mode].setCommandLine(data)
        
    def getCommandLine(self):
        return self.convertDict[self.mode].getCommandLine()
    
    def completed(self):
        return self.convertDict[self.mode].completed()
    def success(self):
        return self.convertDict[self.mode].success()

    def runTime(self):
        return self.convertDict[self.mode].runTime()
    
    def resetStatus(self):
        self.convertDict[self.mode].resetStatus()
    
    def run(self):
        self.convertDict[self.mode].start(self.args)